#ifndef _UI_MOVER_H_
#define _UI_MOVER_H_

#include <string>
#include "math/counter.h"
#include "util/delegate.h"
//image cache
#include "graphics/image_cache.h"
#include "graphics/graphics_util.h"

namespace LuaPlus
{
    class LuaObject;
    class LuaState;
};

namespace ui
{
class UIWidget;

// interface
class UIMover
{
public:
	typedef util::Delegate1<UIMover*>	MoverEvent;
	#define	UIMOVER_DELEGATE(CLASS_ID, FUNCTION_POINTER) UTIL_MAKE_DELEGATE_M(ui::UIMover::MoverEvent, this, CLASS_ID, FUNCTION_POINTER)

	UIMover(UIWidget*	pTarget, float Delay, float Time, bool DoDrop = true);
	virtual			~UIMover() {}
	virtual void	Tick(float dt);
	virtual void	RenderBackground() {}
	virtual void	RenderForeground() {}
	static	void	Register(LuaPlus::LuaState* _pScript);
	void			Invalidate();
	bool			IsFinished() const { return m_Ended; };
	bool			IsRunningScript() const { return m_RunningScript; };
	
	// ADRIAN: widget behavior accessors
	bool			RenderChildren() const	{ return m_RenderChildren; }
	bool			RenderSelf() const		{ return m_RenderSelf; }

	void			SetMoverEvent(MoverEvent	Event) { m_pMoverEvent = Event; };
protected:
	virtual void	OnCountdown();
	virtual void	OnAction(float dt) = 0;
	UIWidget*		m_pTarget;
	std::string		m_Action;
	math::Counter	m_Countdown;
	math::Counter	m_Delay;
	bool			m_DropOnExit;
	bool			m_Invalidated;
	bool			m_Instant;
	bool			m_Ended;
	bool			m_RunningScript;
	MoverEvent		m_pMoverEvent;

	// ADRIAN: Widget behavior flags
	bool			m_RenderChildren;	// render child widgets while this mover is active?
	bool			m_RenderSelf;		// render myself while this mover is active?

	ImageCache*		m_pCache;
};


}// namespace ui

#endif // _UI_MOVER_H_